import type { MockWrapper } from '@alova/mock'
import { createAlovaMockAdapter } from '@alova/mock'
import adapterFetch from 'alova/fetch'

// 默认的fetch适配器
const defaultHttpAdapter = adapterFetch()

// 读取mock列表
const mockApis = import.meta.glob<MockWrapper>(['@/mock/**/*.ts', '!@/mock/_utils.ts'], {
  eager: true,
  import: 'default',
})
const mockList = []
for (const path in mockApis) {
  mockList.push(mockApis[path])
}

const mockAdapter = createAlovaMockAdapter(mockList, {
  httpAdapter: defaultHttpAdapter,
  delay: 200,
  enable: import.meta.env.VITE_MOCK_ENABLED,
})

export { defaultHttpAdapter, mockAdapter }
